package com.achao.javabean.entity;

import lombok.Data;

/**
 * @Author: achao
 * @DateTime: 2022/6/16 14:11
 * @Description: TODO
 */

@Data
public class PageInfo {

    private int total; // 总条数
    private int nowPage; // 当前页
    private int pageSize; // 页面大小
    private int sumPage; // 总页码 ()

    public PageInfo() {
    }

    public PageInfo(int total, int nowPage, int pageSize) {
        this.total = total;
        this.nowPage = nowPage;
        this.pageSize = pageSize;
        if (total != 0) {
            if (total % pageSize == 0) {
                this.sumPage = total / pageSize;
            } else {
                this.sumPage = (total / pageSize) + 1;
            }
        } else {
            this.sumPage = 1;
        }
    }

    public void setMyPage(int total, int nowPage, int pageSize) {
        this.total = total;
        this.nowPage = nowPage;
        this.pageSize = pageSize;
        if (total != 0) {
            if (total % pageSize == 0) {
                this.sumPage = total / pageSize;
            } else {
                this.sumPage = (total / pageSize) + 1;
            }
        } else {
            this.sumPage = 1;
        }
    }
}
